package com.example.demo2;

import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("Re")
@RestController

//@Controller
public class Reponse {
    @RequestMapping("/r1")

    public String request(){
        return "index.html";
    }

    @RequestMapping("/r2")
    public String request1(){
        return "/index1.html";
    }


    @ResponseBody
    @RequestMapping("/r3")
    public String request3(){
        return "我是返回数据";
    }

    @RequestMapping(value = "/r4",produces = "text/plain")
    public String r4(){
        return "<h1>我是标题1</h1>";
    }

    @RequestMapping(value = "/r5")
    public String r5(){
        return "<h1>我是标题1</h1>";
    }

    @RequestMapping(value = "/r6")
    public UserInfo r6(){
        UserInfo userInfo=new UserInfo("张三",18,"男");
        return userInfo;
    }

    @RequestMapping(value = "/r7")
    public UserInfo r7(HttpServletResponse response){
        response.setStatus(404);
        UserInfo userInfo=new UserInfo("张三",18,"男");
        return userInfo;
    }

}
